package com.mwf.infrastructure.dcc;

import com.mwf.types.annotations.DCCValue;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class DCCService {
    @DCCValue("downgradeSwitch:0")
    private String downgradeSwitch;

    @DCCValue("cutRange:100")
    private String cutRange;

    public boolean isDowngradeSwitch() {
        return "1".equals(downgradeSwitch);
    }

    public boolean isCutRange(String userId) {
        int abs = Math.abs(userId.hashCode());
        int lastTwoDigits = abs % 100;
        return lastTwoDigits <= Integer.parseInt(cutRange);
    }
}
